#include "qbcisource.h"

namespace bci {
QBciSource::QBciSource(const QString &id) : QBciMod(id) {
  qRegisterMetaType<QBciSignal>("QBciSignal");
  qRegisterMetaType<QSharedPointer<QBciSignal>>("QSharedPointer<QBciSignal>");
}

void QBciSource::afterStart() {
  QMetaObject::invokeMethod(this, &QBciSource::privateRun,
                            Qt::QueuedConnection);
}

void QBciSource::privateRun() {
  if (!isRunning())
    return;
  switch (runType) {
  case Slot:
    return;
  case Loop:
    run();
    QMetaObject::invokeMethod(this, &QBciSource::privateRun,
                              Qt::QueuedConnection);
    return;
  };
}

} // namespace bci